<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>atexit</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_001_233">&nbsp;</a>NAME</h4><blockquote>
atexit - register a function to run at process termination
</blockquote><h4><a name = "tag_000_001_234">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="stdlib.h.html">stdlib.h</a>&gt;

int atexit(void (*<i>func</i>)(void));
</code>
</pre>
</blockquote><h4><a name = "tag_000_001_235">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>atexit()</i>
function registers the function pointed to by
<i>func</i>
to be called without arguments.  At normal process termination,
functions registered by
<i>atexit()</i>
are called in the reverse order to that in which they were registered.
Normal termination occurs either by a call to
<i><a href="exit.html">exit()</a></i>
or a return from
<i>main()</i>.
<p>
At least 32 functions can be registered with
<i>atexit()</i>.
<p>
After a successful call to any of the
<i>exec</i>
functions, any
functions previously registered by
<i>atexit()</i>
are no longer registered.
</blockquote><h4><a name = "tag_000_001_236">&nbsp;</a>RETURN VALUE</h4><blockquote>
Upon successful completion,
<i>atexit()</i>
returns 0.  Otherwise, it returns a non-zero value.
</blockquote><h4><a name = "tag_000_001_237">&nbsp;</a>ERRORS</h4><blockquote>
No errors are defined.
</blockquote><h4><a name = "tag_000_001_238">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_001_239">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
The functions registered by a call to
<i>atexit()</i>
must return to ensure that all registered functions are called.
<p>
The application should call
<i><a href="sysconf.html">sysconf()</a></i>
to obtain the value of {ATEXIT_MAX}, the number of functions that can be
registered.  There is no way for an application to tell how many functions
have already been registered with
<i>atexit()</i>.
</blockquote><h4><a name = "tag_000_001_240">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_001_241">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="exit.html">exit()</a></i>,
<i><a href="sysconf.html">sysconf()</a></i>,
<i><a href="stdlib.h.html">&lt;stdlib.h&gt;</a></i>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from the ANSI C standard.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

